<template>
  <div>
    <table-box
      ref="MarginManagement"
      :selected-arry.sync="tableSelected"
      :table-config="tableConfig"
      :other-filters="otherFilters"
      :off-set="-20"
      show-index
      no-request
    />
    <div>
      <daily-record-detail v-if="showDetail" ref="dailyRecordDetail" :visible.sync="showDetail" :detail-data="activatedData" />
    </div>
  </div>
</template>

<script>
import DailyRecordDetail from './component/dailyRecordDetail.vue'
export default {
  name: 'D',
  components: { DailyRecordDetail },
  props: {
    type: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      showDetail: false,
      activatedData: {},
      tableSelected: [],
      otherFilters: [],
      tableConfig: {
        interfacePath: `${process.env.VUE_APP_BASE_API}/api/v1/dailyAssessRecord/page`,
        // hideFuncBar: true,
        setting: [
          {
            prop: 'unitName',
            label: '施工单位名称'
          },
          {
            prop: 'principal',
            label: '施工单位负责人'
          },
          {
            prop: 'assessBatchCode',
            label: '评估批次号'
          },
          {
            prop: 'createTime',
            label: '评估日期',
            type: 'date'
          },
          {
            prop: 'createBy',
            label: '评估人'
          },
          {
            prop: 'assessSumScore',
            label: '评估总分值'
          },
          {
            label: '操作',
            type: 'hidden',
            button: [
              {
                name: '查看详情',
                clickFun: this.checkDetail,
                className: 'table-handelclick-text',
                type: 'text'
              }
            ]
          }
        ]
      }
    }
  },
  created() {
    const obj = this.$route.query
    if (obj.type === 'unitEdit') {
      this.tableConfig.setting[0].type = 'hidden'
      this.otherFilters = [{ 'id': 'unitCode', 'property': 'unitCode', 'operator': '=', 'value': obj.unitCode }]
    }
    this.$nextTick(() => {
      this.$refs.MarginManagement.initTableData()
    })
  },
  activated() {},
  methods: {
    checkDetail(data) {
      this.activatedData.flag = 'record'
      this.activatedData.data = data
      this.showDetail = true
    }
  }
}
</script>

<style lang="scss" scoped>
/deep/.table-handelclick-text {
  color: #3DC094;
  cursor: pointer;
}
</style>
